﻿using Company.Core.Config;
using Company.Hardware;
using Company.Sqlite.Interfaces;
using Company.Sqlite.Repositories;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 无人值守地磅称重系统.Interfaces;
using 无人值守地磅称重系统.Services;
using 无人值守地磅称重系统.ViewModels;
using 无人值守地磅称重系统.Views;

namespace 无人值守地磅称重系统.Configure
{
    internal class ConfigureService
    {
        public static IServiceProvider Load()
        {
            var services = new ServiceCollection();

            // 注册数据层
            services.AddSingleton<IUserRepository, UserRepository>();
            services.AddSingleton<ICompanyRepository, CompanyRepository>();
            services.AddSingleton<IStuffRepository, StuffRepository>();
            services.AddSingleton<ICarRepository, CarRepository>();
            services.AddSingleton<IDataRepository, DataRepository>();

            // 注册业务层
            services.AddSingleton<ISession, Session>();
            services.AddSingleton<IConfigManager, ConfigManager>();
            services.AddSingleton<ICamera, Camera>();
            services.AddSingleton<IConfigService, ConfigService>();
            services.AddSingleton<IHardwareManager, HardwareManager>();
            services.AddSingleton<IScale, Scale>();
            services.AddSingleton<IPrintService, PrintService>();
            services.AddSingleton<ICameraIce, CameraIce>();

            // 注册UI层
            services.AddSingleton<ShellView>();
            services.AddSingleton<ShellViewModel>();

            services.AddSingleton<LoginView>();
            services.AddSingleton<LoginViewModel>();

            services.AddSingleton<MainView>();
            services.AddSingleton<MainViewModel>();

            services.AddSingleton<IndexView>();
            services.AddSingleton<IndexViewModel>();

            services.AddSingleton<ReportView>();
            services.AddSingleton<ReportViewModel>();

            services.AddSingleton<CarView>();
            services.AddSingleton<CarViewModel>();

            services.AddSingleton<StuffView>();
            services.AddSingleton<StuffViewModel>();

            services.AddSingleton<CompanyView>();
            services.AddSingleton<CompanyViewModel>();

            services.AddSingleton<UserView>();
            services.AddSingleton<UserViewModel>();

            services.AddSingleton<ConfigView>();
            services.AddSingleton<ConfigViewModel>();

            services.AddSingleton<TestView>();
            services.AddSingleton<TestViewModel>();

            return services.BuildServiceProvider();
        }
    }
}
